﻿using AnChao.WPF.Controls.Prism.Core;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Text;

namespace AnChao.WPF.Controls.Prism.ViewModels
{
    public class GetHourTabViewModel : BindableBase
    {
        IApplicationCommands _applicationCommands;

        public GetHourTabViewModel(IApplicationCommands applicationCommands)
        {
            _applicationCommands = applicationCommands;
            _applicationCommands.GetCurrentAllTimeCommand.RegisterCommand(GetHourCommand);
        }

        private bool _isCanExcute;
        public bool IsCanExcute
        {
            get
            {
                return _isCanExcute;
            }
            set
            {
                SetProperty(ref _isCanExcute, value);
            }
        }

        private string _currentHour; 
        public string CurrentHour
        {
            get 
            {
                return _currentHour;
            }
            set 
            {
                SetProperty(ref _currentHour, value);
            }
        }

        private DelegateCommand _getHourCommand;
        public DelegateCommand GetHourCommand =>
            _getHourCommand ?? (_getHourCommand = new DelegateCommand(ExecuteGetHourCommand)).ObservesCanExecute(() => IsCanExcute);

        private void ExecuteGetHourCommand()
        {
            CurrentHour = DateTime.Now.ToString("HH:ss:mm");
        }

        private string _title;
        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                SetProperty(ref _title, value);
            }
        }
    }
}
